var banner = document.querySelector('.container .imgarea a');
var tittleUlDom = document.querySelector('.container .slidebar ul');

function init() {
  loadTittle();
  startBanner();
}
/**
 * 启动图片切换
 * @returns
 */
var curIndex = 0;
var timerId = null;

function startBanner() {
  if (timerId) {
    return;
  }
  timerId = setInterval(() => {
    curIndex++;
    if (curIndex >= data.length) {
      curIndex = 0;
    }
    var item = data[curIndex];
    banner.style.backgroundImage = `url(${item.img})`;
    banner.style.backgroundColor = item.bg;
  }, 2000);
}

/**
 * 加载标题
 */
function loadTittle() {
  for (var i = 0; i < data.length; i++) {
    var item = data[i];
    var li = document.createElement('li');
    li.innerHTML = '<li class="movieitem">
    <span class="moviename">${item.title}</span>
    <span class="moviedesc">${item.desc}</span>
  </li>';
  }
}
init();
